package com.caipiao.crawler.run;

import com.caipiao.constant.CrawlerConstants;
import com.caipiao.crawler.daletou.DaletouResultPage;
import com.caipiao.crawler.daletou.DaletouResultPipeline;
import com.caipiao.crawler.pailie.Pailie5DetailPage;
import com.caipiao.crawler.pailie.Pailie5DetailPipeline;
import com.caipiao.crawler.pailie.PailieResultPage;
import com.caipiao.crawler.pailie.PailieResultPipeline;
import com.caipiao.crawler.qixingcai.QixingcaiResultPage;
import com.caipiao.crawler.qixingcai.QixingcaiResultPipeline;
import us.codecraft.webmagic.Spider;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by adminitrator on 2018/7/28.
 */
public class Pailie implements RunCrawler {

    @Override
    public void run() {
        Spider.create(new PailieResultPage())
                .addUrl(CrawlerConstants.PAILIE_HISTORY_URL)
                .addPipeline(new PailieResultPipeline())
                .thread(4)
                .run();
    }

    @Override
    public void runHistory() {
        List<String> urls = new ArrayList<String>();
        for (int i = 18176; i < 18205; i++) {
            urls.add(CrawlerConstants.PAILIE_DATA_URL + i);
        }
        Spider.create(new PailieResultPage())
                .addUrl(urls.toArray(new String[0]))
                .addPipeline(new PailieResultPipeline())
                .thread(4)
                .run();
    }

    //更新排列五奖金池

    public void runSalesAndPool(){
        Spider.create(new Pailie5DetailPage())
                .addUrl(CrawlerConstants.PAILIE5_HISTORY_URL)
                .addPipeline(new Pailie5DetailPipeline())
                .thread(4)
                .run();
    }
}
